home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / share / Dos / VARIOS / pascal / SWAG9605.DDD / 0058_Multiple File Delete.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-05-31  |  1.5 KB  |  69 lines

  1. {
  2. DELM - Multiple delete
  3.  
  4. (C) 1996 Scott Tunstall.
  5.  
  6. Without entering any crap utils like CO, DR etc you can do this
  7. straight from the command line.. nice 'n' easy !! :)
  8.  
  9. }
  10.  
  11.  
  12. Uses Dos;
  13.  
  14. Procedure Usage;
  15. Begin
  16.      Writeln;
  17.      Writeln;
  18.      Writeln('DELM - Delete Multiple Files quickly via command line.');
  19.      Writeln('(C) 1996 Scott Tunstall. All rights reserved.');
  20.      Writeln;
  21.      Writeln('Usage :');
  22.      Writeln;
  23.      Writeln('DELM <FileSpec1> [FileSpec2] [FileSpec3..]');
  24.      Writeln;
  25.      Writeln;
  26. End;
  27.  
  28.  
  29.  
  30. Procedure RemoveFiles(FirstParmToUse, EndParm: byte);
  31. Var
  32.     Fails: byte;                { No of missed files }
  33.     Count: byte;
  34.     Rec: SearchRec;
  35.     FileToErase: file;
  36.  
  37. Begin
  38.      Fails:=0;
  39.      For Count:=FirstParmToUse To EndParm do
  40.          Begin
  41.          FindFirst(ParamStr(Count), $2F, Rec);
  42.          If DosError <>0 Then
  43.             Begin
  44.             Writeln('No file matches the pattern ', ParamStr(Count), '!');
  45.             Inc(Fails);
  46.             End
  47.          Else
  48.              while DosError = 0 do
  49.              Begin
  50.                   Writeln('Deleting ', Rec.Name, '.');
  51.                   Assign(FileToErase, Rec.Name);
  52.                   {$i-}
  53.                   Erase(FileToErase);
  54.                   {$i+}
  55.                   FindNext(Rec);
  56.              End;
  57.      End;
  58.      Halt(Fails);
  59. End;
  60.  
  61.  
  62.  
  63.  
  64. Begin
  65.      If ParamCount = 0 Then
  66.         Usage
  67.      Else
  68.          RemoveFiles(1, ParamCount);
  69. End.